<template>
  <div class="section_common">
    <div class="main">
      <el-form ref="form" label-width="100px">

        <el-form-item label="所属仓库" required>
          <el-radio v-model="area" label="1">东莞仓</el-radio>
          <el-radio v-model="area" label="2">上雪仓</el-radio>
        </el-form-item>

        <el-form-item label="费用名称" required>
          <el-input v-model="costname" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="实际用途" required>
          <el-input v-model="tuse" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="金额(元)" required>
          <el-input v-model="money" size="mini" @keyup.enter="comdify"  @input="comdify"></el-input><!--v-on:keyup="comdify"-->
        </el-form-item>
        <el-form-item label="特殊备注">
          <el-input v-model="other" size="mini"></el-input>
        </el-form-item>

        <el-form-item>

        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import { } from "vant";
export default {
  data() {
    return {
      area:"1",
      costname:"",
      tuse:"",
      money:"",
      other:"",

      nowUser:"",
      title: "费用登记",

      addExpenseApply: '/mobiles/addExpenseApply',

    };
  },
  created() {
    this.nowUser=JSON.parse(localStorage.getItem('userInfo')).userId;
    this.id= this.$route.params.id;
    this.getExpenseInfo();
  },
  methods: {

    comdify() {
      this.money = this.money.replace(/[^\d.]/g, "");
      let re = /\d{1,3}(?=(\d{3})+$)/g;
      let n1 = this.money.replace(/^(\d+)((\.\d+)?)$/, function (s, s1, s2) {
        return s1.replace(re, "$&,") + s2;
      });
      //return n1;
      this.money=n1;
    },

    getExpenseInfo(){
      this.$https.post('/mobiles/getExpenseInfo',{
        nowUser:this.nowUser,
        id:this.id
      }).then((res)=>{

        this.area=res.data.data.area;
        this.costname=res.data.data.costname;
        this.tuse=res.data.data.tuse;
        this.money=res.data.data.money;
        this.other=res.data.data.other;

      }).catch(err => {
        console.log(err);
      })
    },
    // 返回
    goBack() {
      this.$router.go(-1);
    },

  },
};
</script>

<style lang="scss" scoped>
.main {
  display: flex;
  justify-items: center;
  margin: 0 auto;
  .el-form {
    padding-right: 10px;
    .el-form-item {
      .el-form-item__label {
        line-height: 16px;
      }
      margin-bottom: 5px;
    }
  }
}
</style>